package com.mq.send;

import com.mq.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author xwj
 * @date 2019/8/8
 */
@Component
public class DelaySend {
    private static Logger logger = LoggerFactory.getLogger(DelaySend.class);
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendDelay5s(User user) {
        CorrelationData correlationData = new CorrelationData(user.getId());
        rabbitTemplate.convertAndSend("delay_direct", "5s", user, correlationData);
    }

}
